home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / amok_lha / amok24.lha / TurboFiles / SpeedCheck.mod < prev    next >
Text File  |  1993-08-15  |  3KB  |  119 lines

  1. (**********************************************************************
  2.   :Program.    SpeedCheck.mod
  3.   :Contents.   Compares the speed of Dos, AM-FileSystem and TurboFiles.
  4.   :Author.     Stefan Salewski
  5.   :Copyright.  Public Domain
  6.   :Language.   Modula-2
  7.   :Translator. M2Amiga AMSoft V3.2d
  8.   :History.    V1.0 1.Jul.1989
  9.   :Address.    Stolper Weg 3, D-2160 Stade
  10. **********************************************************************)
  11.  
  12. MODULE SpeedCheck;
  13. (* This is only a simpel testprogram. I write it down in less than
  14.    one hour, so please don't look at this code
  15. *)
  16. FROM InOut IMPORT WriteString,WriteInt,WriteLn,Write,ReadLongInt,ReadString;
  17. FROM RealInOut IMPORT WriteReal;
  18. FROM Timer2 IMPORT StartTime,StopTime;
  19. FROM Timer IMPORT TimeVal;
  20. FROM SYSTEM IMPORT ADR;
  21. IMPORT FileSystem;
  22. IMPORT TurboFiles;
  23. IMPORT Dos;
  24.  
  25. CONST
  26.   Runnings=7;
  27.  
  28. PROCEDURE WriteTime(t:TimeVal);
  29. VAR
  30.   time:REAL;
  31. BEGIN
  32.   time:=REAL(t.secs)+REAL(t.micro)*1.0E-6;
  33.   WriteReal(time,12,3);
  34. END WriteTime;
  35.  
  36. VAR
  37.   amFile:FileSystem.File;
  38.   turboFile:TurboFiles.FilePtr;
  39.   l,bufferSize:LONGINT;
  40.   fileName:ARRAY[0..80] OF CHAR;
  41.   t:TimeVal;
  42.   fPtr:Dos.FileHandlePtr;
  43.   buffer:ARRAY[0..10240] OF CHAR;
  44.   i:INTEGER;
  45.   blockSize:ARRAY[1..Runnings] OF LONGINT;
  46.  
  47. BEGIN
  48.   blockSize[1]:=1;
  49.   blockSize[2]:=4;
  50.   blockSize[3]:=16;
  51.   blockSize[4]:=64;
  52.   blockSize[5]:=256;
  53.   blockSize[6]:=480;
  54.   blockSize[7]:=720;
  55.   WriteString('Test of the Speed of the Procedures');WriteLn;
  56.   WriteString('Dos.Read, FileSystem.ReadBytes, ');
  57.   WriteString('TurboFiles.ReadBytes and TurboFiles.TurboRead');
  58.   WriteLn;
  59.   WriteString('Name of the file to read: ');
  60.   ReadString(fileName);WriteLn;
  61.   WriteString('Buffersize for FileSystem and TurboFiles: (0-10240): ');
  62.   ReadLongInt(bufferSize);
  63.   WriteString('BlockSize     Dos:Read  FS:ReadBytes TF:ReadBytes TF:TurboRead');
  64.   WriteLn;
  65.   IF (bufferSize<=10240) AND (bufferSize>=0) THEN
  66.     FOR i:=1 TO Runnings DO
  67.       WriteLn;
  68.       WriteInt(blockSize[i],4);WriteString('      ');
  69.       
  70.       StartTime();
  71.       fPtr:=Dos.Open(ADR(fileName),Dos.readWrite);
  72.       IF fPtr#NIL THEN
  73.         REPEAT
  74.           l:=Dos.Read(fPtr,ADR(buffer),blockSize[i])
  75.         UNTIL l=0;
  76.         Dos.Close(fPtr);
  77.         StopTime(t);
  78.         WriteTime(t);
  79.       END;
  80.       
  81.       StartTime();
  82.       FileSystem.Lookup(amFile,fileName,bufferSize,FALSE);
  83.       IF amFile.res=FileSystem.done THEN
  84.         REPEAT
  85.           FileSystem.ReadBytes(amFile,ADR(buffer),blockSize[i],l)
  86.         UNTIL l=0;
  87.         FileSystem.Close(amFile);
  88.         StopTime(t);
  89.         WriteTime(t);
  90.       END;
  91.       
  92.       StartTime();
  93.       IF TurboFiles.Lookup(turboFile,fileName,bufferSize,TurboFiles.ReadOnly)
  94.          =TurboFiles.done THEN
  95.         REPEAT
  96.           TurboFiles.ReadBytes(turboFile,ADR(buffer),blockSize[i],l)
  97.         UNTIL turboFile^.res#TurboFiles.done;
  98.         TurboFiles.CloseFile(turboFile);
  99.         StopTime(t);
  100.         WriteTime(t);
  101.       END;
  102.       
  103.       StartTime();
  104.       IF TurboFiles.Lookup(turboFile,fileName,bufferSize,TurboFiles.ReadOnly)
  105.          =TurboFiles.done THEN
  106.         REPEAT
  107.           TurboFiles.TurboRead(turboFile,ADR(buffer),blockSize[i],l)
  108.         UNTIL turboFile^.res#TurboFiles.done;
  109.         TurboFiles.CloseFile(turboFile);
  110.         StopTime(t);
  111.         WriteTime(t);
  112.       END;
  113.       
  114.     END;
  115.     WriteLn;WriteLn;
  116.     WriteString('Click CloseGadget to Exit');WriteLn;
  117.   END;    
  118. END SpeedCheck.
  119.